package com.bkgy.config;

import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;

import javax.jms.ConnectionFactory;

@Configuration
public class ActiveMQConfig {

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer01(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy001");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer02(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy002");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer03(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy003");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer04(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy004");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer05(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy005");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer06(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy006");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer07(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy007");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer08(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy008");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }

    @Bean
    public JmsListenerContainerFactory<?> topicListenerContainer09(ConnectionFactory activeMQConnectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer) {
        DefaultJmsListenerContainerFactory topicListenerContainer = new DefaultJmsListenerContainerFactory();
        configurer.configure(topicListenerContainer,activeMQConnectionFactory);
        topicListenerContainer.setConnectionFactory(activeMQConnectionFactory);
        topicListenerContainer.setPubSubDomain(true);
        topicListenerContainer.setClientId("bkgy009");
        topicListenerContainer.setSubscriptionDurable(true);
        return topicListenerContainer;
    }
}
